package ruifeng.zcj.happymahjony.util;

/**
 * Created by Administrator on 2016/9/21 0021.
 */
public class CacheApi {

    /***
     * 保存登录的用户信息
     **/
    public static void cacheStringUserMessage(String user, String name) {
        if (CacheUtil.readString(name) != null) {
            CacheUtil.clear(name);
        }
        CacheUtil.cacheString(name, user);
    }

    /***
     * 读取登录的用户信息
     **/
    public static String readStringUserMessage(String name) {
        String base = CacheUtil.readString(name);
        if (CacheUtil.readString(name) != null) {
            return base;
        }
        return null;
    }

    /***
     * 保存登录的用户信息
     **/
    public static void cacheUserMessage(Base user, String name) {
        if (CacheUtil.readObject(name) != null) {
            CacheUtil.clear(name);
        }
        CacheUtil.cacheSerializable(name, user);
    }

    /***
     * 读取登录的用户信息
     **/
    public static Base readUserMessage(String name) {
        Base base = (Base) CacheUtil.readObject(name);
        if (CacheUtil.readObject(name) != null) {
            return base;
        }
        return null;
    }

    /***
     * 记录列表上次刷新时间
     *
     * @param key
     * @param value
     * @return void
     * @author 火蚁 2015-2-9 下午2:21:37
     */
    public static void putToLastRefreshTime(String key, String value) {
        if (CacheUtil.readString(key) != null) {
            CacheUtil.clear(key);
        }
        CacheUtil.cacheString(key, value);
    }

    /***
     * 获取列表的上次刷新时间
     *
     * @param key
     * @return
     * @author
     */
    public static String getLastRefreshTime(String key) {
        return CacheUtil.readString(key);
    }

}
